package com.cn.tous.auth.security;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationContext;
import org.springframework.security.oauth2.server.authorization.context.AuthorizationServerContext;
import org.springframework.security.oauth2.server.authorization.settings.AuthorizationServerSettings;
import org.springframework.stereotype.Component;

/**
 * @author mengwei
 * @description PasswordAuthorizationServerContext
 * @createDate 2025/7/30 11:50
 */
@Component
public class PasswordAuthorizationServerContext implements AuthorizationServerContext {

    private AuthorizationServerSettings authorizationServerSettings;

    @Value("${authorization.server.issuer}")
    private String issuer;

    @Autowired
    private ApplicationContext applicationContext;






    @Override
    public String getIssuer() {
        return issuer;
    }

    @Override
    public AuthorizationServerSettings getAuthorizationServerSettings() {
        if (authorizationServerSettings == null) {
            authorizationServerSettings = applicationContext.getBean(AuthorizationServerSettings.class);
        }
        return authorizationServerSettings;
    }
}
